package com.dbqn.zhao.service.impl;

import com.dbqn.zhao.entity.Novel;
import com.dbqn.zhao.entity.User;
import com.dbqn.zhao.service.BaseService;
import com.dbqn.zhao.service.UserService;
import com.dbqn.zhao.util.ServiceFactory;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class XslxServiceImpl implements BaseService, UserService {

    List list1=new ArrayList();//存储言情小说信息的集合
    List lis2=new ArrayList();//存储武侠小说信息的集合
    Scanner sc=new Scanner(System.in);

    @Override
    public List execute(List list) {

        Novel novel=new Novel();
        novel.setBookname("雪山飞孤");
        novel.setName("金庸");
        novel.setJianjie("长篇小说");
        list1.add(novel);

        Novel novel2=new Novel();
        novel2.setBookname("顾夏金玉");
        novel2.setName("顾夏");
        novel2.setJianjie("短篇小说");
        list1.add(novel2);


        Novel novel3=new Novel();
        novel3.setBookname("天龙八部");
        novel3.setName("飞飞");
        novel3.setJianjie("长篇小说");
        lis2.add(novel3);

        Novel novel4=new Novel();
        novel4.setBookname("顾夏金玉");
        novel4.setName("顾夏");
        novel4.setJianjie("短篇小说");
        lis2.add(novel4);


        for(;;){
         System.out.println("0:退出登录");
         System.out.println("1:言情");
         System.out.println("2:武侠");
         System.out.println("----------------------------");
         System.out.println("请选择:");
            int xz= 0;

            try {
                xz = sc.nextInt();
            } catch (Exception e) {
                e.printStackTrace();
                System.out.println("请输入数字！");
            }


            switch (xz){

             case 0:
                 System.out.println("退出成功！欢迎下次再来！");
                 System.exit(0);//关闭虚拟机，结束程序
                 break;

             case 1:
                 System.out.println("言情小硕");
                 BaseService baseService = ServiceFactory.getService("getnovel");
                 List jiess=baseService.execute(list1);

                 if(jiess==null){
                     continue;
                 }

                 break;

             case 2:
                 System.out.println("武侠小说");
                 BaseService baseService2 = ServiceFactory.getService("sword");
                 List jies=baseService2.execute(lis2);

                 if(jies==null){
                     continue;
                 }

                 break;

             default:
                 System.out.println("您输入的有误，请重新输入;");
                 break;

         }
         return null;
     }


    }

    @Override
    public int insert(List list) {
        return 0;
    }

    @Override
    public User login(List list, User user) {
        return null;
    }
}
